package com.five.community.service.impl;

import com.five.community.bean.Parking;
import com.five.community.bean.vo.ParkingVo;
import com.five.community.mapper.ParkingMapper;
import com.five.community.service.ParkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/*
    车位管理业务层实现
 */
@Service
public class ParkingServiceImpl implements ParkingService {

    @Autowired
    private ParkingMapper parkingMapper;

    // 查询全部数据
    @Override
    public List<Parking> selectAll() throws Exception {
        return parkingMapper.selectAll();
    }

    // 插入数据
    @Override
    public void insert(Parking parking) throws Exception {
        parkingMapper.insert(parking);
    }

    // 根据编号查询
    @Override
    public Parking selectById(long id) throws Exception {
        return parkingMapper.selectById(id);
    }

    // 根据编号更新数据
    @Override
    public void updateById(Parking parking) throws Exception {
        parkingMapper.updateById(parking);
    }

    // 根据编号更新车位的状态为false
    @Override
    public void updateStateByPid(long id) throws Exception {
        parkingMapper.updateStateByPid(id);
    }

    // 根据编号更新车位的状态为true
    @Override
    public void updateStateByPid2(long id) throws Exception {
        parkingMapper.updateStateByPid2(id);
    }

    // 根据编号删除
    @Override
    public void deleteById(long id) throws Exception {
        parkingMapper.deleteById(id);
    }

    // 根据所属小区编号查询车位信息和小区名称
    @Override
    public List<ParkingVo> selectAllAndVname() throws Exception {
        return parkingMapper.selectAllAndVname();
    }

    // 根据小区名称查询车位信息和所属小区名称
    @Override
    public List<ParkingVo> selectParkingAndVnameByVname(String vname) throws Exception {
        return parkingMapper.selectParkingAndVnameByVname(vname);
    }


}
